Use "-pthread" when compiling as well as when linking. As per the gcc(1) manual page: "This option sets flags for both the preprocessor and linker." In practice, that means -D_REENTRANT and -lpthread, respectively, or the equivalent flags for the platform. Change-Id: I8cda318f00f0a9c9111bf07780298a41720a7229 Reviewed-on: https://code-review.googlesource.com/3941 Reviewed-by: Stefano Rivera <stefano@rivera.za.net> Reviewed-by: Paul Wankadia <junyer@google.com> 
diff --git a/BUILD b/BUILD index 9ab54b3..0e042f9 100644 --- a/BUILD +++ b/BUILD 
@@ -59,6 +59,7 @@  "re2/stringpiece.h",  "re2/variadic_function.h",  ], + copts = ["-pthread"],  includes = ["."],  linkopts = ["-pthread"],  visibility = ["//visibility:public"], 
diff --git a/CMakeLists.txt b/CMakeLists.txt index c6c6060..1c980df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt 
@@ -15,6 +15,7 @@  add_definitions(-DUNICODE -D_UNICODE -DSTRICT -DNOMINMAX)  set(THREADING threadwin)  else() + add_definitions(-pthread)  set(THREADING thread)  list(APPEND EXTRA_TARGET_LINK_LIBRARIES -pthread)  endif() 
diff --git a/Makefile b/Makefile index 5068459..577fa12 100644 --- a/Makefile +++ b/Makefile 
@@ -8,7 +8,7 @@  # LDPCRE=-L/usr/local/lib -lpcre    CXX?=g++ -CXXFLAGS?=-O3 -g # can override +CXXFLAGS?=-O3 -g -pthread # can override  RE2_CXXFLAGS?=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I. $(CCPCRE) # required  LDFLAGS?=-pthread  AR?=ar 
diff --git a/re2.pc b/re2.pc index 9e90cda..82832c3 100644 --- a/re2.pc +++ b/re2.pc 
@@ -6,5 +6,5 @@  Name: re2  Description: RE2 is a fast, safe, thread-friendly regular expression engine.  Version: 0.0.0 -Cflags: -I${includedir} +Cflags: -I${includedir} -pthread  Libs: -L${libdir} -lre2 -pthread